package com.woniuxy.lrz.carlproject.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.woniuxy.lrz.carlproject.common.AppException;
import com.woniuxy.lrz.carlproject.common.util.RandomString;
import com.woniuxy.lrz.carlproject.controller.form.approveform.ShopRegisterForm;
import com.woniuxy.lrz.carlproject.model.Approve;
import com.woniuxy.lrz.carlproject.dao.ApproveMapper;
import com.woniuxy.lrz.carlproject.service.ApproveService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.BoundHashOperations;
import org.springframework.data.redis.core.BoundValueOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lrz
 * @since 2022-09-28
 */
@Service
public class ApproveServiceImpl extends ServiceImpl<ApproveMapper, Approve> implements ApproveService {

    @Resource
    private ApproveMapper approveMapper;

//    @Resource
//    RedisTemplate redisTemplate;
    @Override
//    @Cacheable(cacheNames = "approve", key = "#shopRegisterForm")
    public void addShopRegister(ShopRegisterForm shopRegisterForm) {
        Approve approve = BeanUtil.copyProperties(shopRegisterForm, Approve.class);
        String str = RandomString.Random(20);
        approve.setContractNo(str);
        approve.setStatus("ING");
        int insert = approveMapper.insert(approve);
        if (insert<1){
            throw  new AppException("申请入驻失败");
        }
    }
}
